<form   class="form-horizontal" id="form">
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label">打卡开始时间</label>
        <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
            {php echo tpl_form_field_clock('daka_start_time', $value = $config['daka_start_time']);}
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label">打卡结束时间</label>
        <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
            {php echo tpl_form_field_clock('daka_end_time', $value = $config['daka_end_time']);}
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label">支付方式</label>
        <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
            <div class="radio">
                <label>
                    <input {php echo $config[ 'pay_type']==1? 'checked': '';} type="radio" name="pay_type" value="1"> 方式1(当前页面完成支付;需认证服务号自有支付)
                </label>
            </div>
            <div class="radio">
                <label>
                    <input {php echo $config[ 'pay_type']==2? 'checked': '';} type="radio" name="pay_type" value="2"> 方式2(跳转页面支付;可借权支付;可余额支付)
                </label>
            </div>
            <div style="color:red;font-size:12px;" class="radio">
                <span>
                    请勿频繁切换，否则可能导致订单号重复无法支付
                </span>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label">发放奖励方式</label>
        <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
            <div class="radio">
                <label>
                    <input {php echo $config[ 'fenmoney_type']==1? 'checked': '';} type="radio" name="fenmoney_type" value="1"> 微信现金红包(需要用户点击后领取)
                </label>
            </div>
            <div class="radio">
                <label>
                    <input {php echo $config[ 'fenmoney_type']==2? 'checked': '';} type="radio" name="fenmoney_type" value="2"> 企业付款(直接进入微信零钱)
                </label>
            </div>
            <div class="radio">
                <label>
                    <input {php echo $config[ 'fenmoney_type']==3? 'checked': '';} type="radio" name="fenmoney_type" value="3"> 微擎余额
                </label>
            </div>
            <div style="color:red;font-size:12px;" class="radio">
                <span>
                    若发放到余额，则建议开启支付方式2，让用户可以使用余额参与
                </span>
            </div>
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label">提现打款方式</label>
        <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
            <div class="radio">
                <label>
                    <input {php echo $config[ 'atmtype']==1? 'checked': '';} type="radio" name="atmtype" value="1"> 微信现金红包(需要用户点击后领取)
                </label>
            </div>
            <div class="radio">
                <label>
                    <input {php echo $config[ 'atmtype']==2? 'checked': '';} type="radio" name="atmtype" value="2"> 企业付款(直接进入微信零钱)
                </label>
            </div>
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label">提现自动打款限额</label>
        <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
            <input value="{php echo $config['atmminmoney'];}" type="number" name="atmminmoney" class="form-control" placeholder="请填写提现自动打款限额">
            <span class="help-text">
                如设置为0，则所有提现手工打款<br>
                如设置为10，则10元以下提现自动打款(包含10元)<br>
                如设置为100，则100元以下提现自动打款(包含100元)<br>
                自动打款仅支持现金红包，请登陆pay.weixin.qq.com 产品中心->现金红包->产品设置->用户领取上限->建议设置为1
            </span>
        </div>
    </div>

    <div   class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label">单笔参与金额</label>
        <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
            <input value="{php echo $config['per_money'];}" type="number" name="per_money" class="form-control" placeholder="请填写单笔参与金额">
            <span class="help-text">
            </span>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label">支付按钮显示文字</label>
        <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
            <input value="{php echo $config['paybtntext'];}" type="text" name="paybtntext" class="form-control" placeholder="支付按钮显示文字">
            <span class="help-text">
            </span>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label">参与方式</label>
        <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
            <template v-for="(item,index) in paylist">
                <div style="margin:10px 0;">
                    描述：
                    <input v-model="item.name" name="paytext[]"> 金额：
                    <input v-model="item.value" name="paymoney[]">
                    <a @click="delitem(index)">删除</a>
                </div>
            </template>
            <a @click="addpay()" class="btn btn-success">添加参与方式</a>
            <span class="help-text">
                改项设置后，单笔参与金额将失效
            </span>
        </div>
    </div>  
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label">规则内容</label>
        <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
            <textarea type="text" name="rule" class="form-control" placeholder="规则内容">{$config['rule']}</textarea>
            <div>
            </div>
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label">公告内容</label>
        <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
            <input value="{php echo $config['notice'];}" type="text" name="notice" class="form-control" placeholder="公告内容">
            <div>
            </div>
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label">发放奖励密钥</label>
        <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
            <input value="{php echo $config['cronkey'];}" type="text" name="cronkey" class="form-control" placeholder="发放奖励密钥">
            <div>
                随机字符串（数字字母混合），若设置该项则只有使用此密钥才能执行奖励发放
            </div>
        </div>
    </div>
    
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label">打卡赠送积分</label>
        <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
            <input value="{php echo $config['score'];}" type="number" name="score" class="form-control" placeholder="请填写赠送积分">
            <span class="help-text">
                用户成功打卡后赠送的积分金额
            </span>
        </div>
    </div>
    
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label">推荐奖励现金</label>
        <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
            <input value="{php echo $config['refer_money'];}" type="number" name="refer_money" class="form-control" placeholder="推荐奖励现金">
            <span class="help-text">
                成功推荐奖励一人奖励金额（要求：通过扫描用户二维码绑定上下级，首次付费参与）
            </span>
        </div>
    </div>
    
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label">税率</label>
        <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
            <input value="{php echo $config['tax_bili'];}" type="number" name="tax_bili" class="form-control" placeholder="请填写税率">
            <span class="help-text">
                若填写为0.01,会从未打卡的资金里扣取1%
                <br> 注意：单人奖励不满1元时，至少发放1元
            </span>
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label">引导关注链接</label>
        <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
            <input value="{php echo $config['sub_url'];}" type="text" name="sub_url" class="form-control" placeholder="请填写链接">
            <span class="help-text">
                建议配合模块
                <a target="_blank" href="https://s.we7.cc/module-6948.html">https://s.we7.cc/module-6948.html</a>使用
            </span>
        </div>
    </div>


    <div id="share-data">
        <div class="page-header">
            <h4>分享相关设置</h4>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">首页显示标题</label>
            <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
                <input value="{php echo $config['index_title'];}" type="text" name="index_title" class="form-control" placeholder="请填写">
                <span class="help-text">
                </span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">分享标题形式</label>
            <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
                <div class="radio">
                    <label>
                        <input {php echo $config[ 'share_type']==1? 'checked': '';} type="radio" name="share_type" value="1"> 手工设置(请在下方设置分享标题)
                    </label>
                </div>
                <div class="radio">
                    <label>
                        <input {php echo $config[ 'share_type']==2? 'checked': '';} type="radio" name="share_type" value="2"> 自动生成(我已打卡X天，累计赚取X元)
                    </label>
                </div>
                <div style="color:red;font-size:12px;" class="radio">
                    <span>
                    </span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">分享标题</label>
            <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
                <input value="{php echo $config['share_title'];}" type="text" name="share_title" class="form-control" placeholder="请填写">
                <span class="help-text">
                </span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">分享文字简述</label>
            <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
                <input value="{php echo $config['share_des'];}" type="text" name="share_des" class="form-control" placeholder="请填写分享文字简述">
                <span class="help-text">
                </span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">分享主图</label>
            <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
                {php echo tpl_form_field_image('share_img', $config['share_img'], $default = '', $options = array());}
                <span class="help-text">
                </span>
            </div>
        </div>
    </div>

    <div id="ad-data">
        <div class="page-header">
            <h4>广告设置</h4>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">广告主图</label>
            <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
                {php echo tpl_form_field_image('ad_imgurl', $config['ad_imgurl'], $default = '', $options = array());}
                <span class="help-text">
                    有主图首页就会显示
                </span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-12 col-sm-3 col-md-2 control-label">广告链接</label>
            <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
                <input value="{php echo $config['ad_url'];}" type="text" name="ad_url" class="form-control" placeholder="请填写">
                <span class="help-text">
                    非必填
                </span>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label">调试模式</label>
        <div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
            <div class="radio">
                <label>
                    <input {php echo $config[ 'is_debug']==1? 'checked': '';} type="radio" name="is_debug" value="1"> 关闭
                </label>
            </div>
            <div class="radio">
                <label>
                    <input {php echo $config[ 'is_debug']==2? 'checked': '';} type="radio" name="is_debug" value="2"> 开启
                </label>
            </div>
            <div style="color:red;font-size:12px;" class="radio">
                <span>
                </span>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
        <div class="col-xs-12 col-sm-3 col-md-2 col-lg-2">
            <a type="button" onclick="submit()" class="btn btn-primary">提交</a>
        </div>
    </div>
</form>

<script>
    function submit() {
        var data = $('#form').serialize();
        $.ajax({
            url: window.location.href,
            data: data,
            type: 'post',
            dataType: 'json',
        }).then(function (res) {
            if (res.ret == 0) {
                util.message('修改成功');
            } else {
                util.message(res.message, '', 'error');
            }
        });
    }

    var app = new Vue({
        el: '#form',
        data: {
            paylist: {php echo $config["pay_list"];}
        },
        methods: {
            addpay: function () {
                this.paylist.push({
                    text: '参与方式',
                    money: 0
                });
            },
            delitem: function (index) {
                this.paylist.splice(index, 1);
            }
        }
    });
    $('textarea').flexText();

</script>